﻿using Biz.EF.Platform;
using Hjt212Parser;
using log4net;
using System;
using System.Linq;


namespace TcpServer.DataProcessor
{
    class Platform9012Processor
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(Platform9012Processor));

        public static void Persist(DustContext context, string msg)
        {
            var mn = Parser.GetStringByKey("MN", msg);
            if (string.IsNullOrWhiteSpace(mn))
            {
                return;
            }

            try
            {
                log.Info(msg);
                //有效字符串
                if (Parser.IsLengthRight(msg))
                {
                    //获取QN
                    var qn = Parser.GetStringByKey("QN", msg);


                    var items = context.SetFactorThresholds.Where(t => t.QN != null && t.QN.Contains(qn));
                    foreach (var item in items)
                    {
                        item.执行结果 = "同步成功";

                    }
                    context.SaveChanges();

                }
            }
            catch (Exception ex)
            {
                log.Error(ex);

            }
        }

    }
}
